﻿using System;
using System.IO;

using MbUnit.Framework;

namespace Abstract2ion.Tests
{
	public class FileSystemTestFixtureBase
	{
		protected const string FileExtension = ".txt";
		protected const string FirstFileName = "Test1" + FileExtension;
		protected const string SecondFileName = "Test2" + FileExtension;
		protected const string ThirdFileName = "Test3" + FileExtension;
		protected const string InvalidFileName = "Invalid" + FileExtension;
		protected const string FirstDirectoryName = "First";
		protected const string SecondDirectoryName = "Second";
		protected const string InvalidDirectoryName = "Invalid";

		public string BasePath { get; private set; }

		protected string FirstDirectoryPath
		{
			get { return Path.Combine(BasePath, FirstDirectoryName); }
		}

		protected string InvalidDirectoryPath
		{
			get { return Path.Combine(BasePath, InvalidDirectoryName); }
		}

		protected string FirstFilePath
		{
			get { return Path.Combine(BasePath, FirstFileName); }
		}

		protected string InvalidFilePath
		{
			get { return Path.Combine(BasePath, InvalidFileName); }
		}

		[SetUp]
		public void BaseSetup()
		{
			BasePath = Path.Combine(Environment.CurrentDirectory, "TestDirectoryStructure");
			Directory.CreateDirectory(BasePath);
			Directory.CreateDirectory(Path.Combine(BasePath, FirstDirectoryName));
			Directory.CreateDirectory(Path.Combine(BasePath, SecondDirectoryName));
			File.Create(Path.Combine(BasePath, FirstFileName)).Close();
			File.Create(Path.Combine(BasePath, SecondFileName)).Close();
			File.Create(Path.Combine(BasePath, ThirdFileName)).Close();
		}

		[TearDown]
		public void BaseTeardown()
		{
			Directory.Delete(BasePath, true);
		}
	}
}